package br.edu.delta.teste;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.hibernate.Criteria;
import org.hibernate.Session;

import br.edu.delta.model.Usuario;

public class ExemploTransacaoLocal {

	private static EntityManagerFactory factory;

	static {
		factory = Persistence.createEntityManagerFactory("biblioteca_local");
	}

	public static EntityManager getEntityManager() {
		return factory.createEntityManager();
	}

	public static void main(String[] args) {
		
		Session session =(Session) getEntityManager().getDelegate();
		Criteria criteria = session.createCriteria(Usuario.class);
		@SuppressWarnings("unchecked")
		List<Usuario> usuarios = criteria.list();
		for (Usuario usuario : usuarios) {
			System.out.println(usuario.getNome());
		}
		
		
	}
}
